package gxwl.busins.controller;

import com.alibaba.fastjson.JSONObject;
import gxwl.busins.vo.DataListCondition;
import gxwl.busins.vo.ProcessVO;
import gxwl.busins.service.UploadService;
import gxwl.common.combine.ApiController;
import gxwl.common.combine.GetApi;
import gxwl.common.combine.PostApi;
import gxwl.common.page.PageCondition;
import gxwl.common.page.PageList;
import gxwl.common.pojo.CommonResult;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

@ApiController(value = "/api/upload", name = "数据模块")
public class UpLoad {
    private final UploadService uploadService;

    public UpLoad(UploadService uploadService) {
        this.uploadService = uploadService;
    }

    @PostApi(value = "/process",description = "过程数据上传")
    public CommonResult<Boolean> process(@RequestBody String processStr) {
        ProcessVO processVO = JSONObject.parseObject(processStr, ProcessVO.class);
        return CommonResult.data(uploadService.process(processVO));
    }

    @GetApi(value = "/list",description = "过程数据查询")
    public CommonResult<PageList<ProcessVO>> list(@ParameterObject PageCondition pageCondition,
                                                  @ParameterObject DataListCondition searchCondition) {
        return CommonResult.data(uploadService.list(pageCondition,searchCondition));
    }


}
